<template>
  <div class="hello">
    <h1>{{ msg }}</h1>
    <h2 v-if="apiResponse">{{ apiResponse }}</h2>
    <h2 v-else-if="error">{{ error }}</h2>
  </div>
</template>

<script>
import axios from 'axios';

export default {
  name: 'HelloWorld',
  props: {
    msg: String
  },
  data() {
    return {
      apiResponse: null,
      error: null
    };
  },
  mounted() {
    this.fetchData();
  },
  methods: {
    fetchData() {
      this.apiResponse = null;
      this.error = null;
      axios({
        method: 'get', // 将请求方法改为 'get'
        url: 'http://localhost:10181/hzms/hz/hello',
        headers: {
          'Accept': '*/*',
          'Accept-Language': 'zh-CN,zh;q=0.9',
          'Connection': 'keep-alive',
        },
        insecure: true
      })
      .then(response => {
        this.apiResponse = response.data;
      })
      .catch(error => {
        this.error = '请求失败：' + error;
      });
    }
  }
};
</script>

<style scoped>
/* ... 你的样式 ... */
</style>